const Sequelize = require('sequelize')
let db = require('../config/db')
let User = require('./user')

let Education = db.define('education',{
    id:{
        type: Sequelize.INTEGER,
        field: 'id',
        primaryKey:true,
        autoIncrement: true,
        comment: "主键，自增"
    },
    uid:{
        type: Sequelize.INTEGER
    },

    school:{
        type:Sequelize.STRING,
        comment:'學校'
    },
    speciality:{
        type:Sequelize.STRING,
        comment:'专业'
    },
    record:{
        type:Sequelize.STRING,
        comment:'学历'
    },

    isDel:{
        type: Sequelize.INTEGER,
        defaultValue:0,
        comment:'状态，是否删除'
    },
    end_time: {
        type: Sequelize.DATE,
        get() {
            return moment(this.getDataValue('deletedAt')).format('YYYY-MM-DD HH:mm:ss');
        }
    },
    start_time: {
        type: Sequelize.DATE,
        get() {
            return moment(this.getDataValue('deletedAt')).format('YYYY-MM-DD HH:mm:ss');
        }
    },
    deletedAt: {
        type: Sequelize.DATE,
        get() {
            return moment(this.getDataValue('deletedAt')).format('YYYY-MM-DD HH:mm:ss');
        }
    },
    createdAt: {
        type: Sequelize.DATE,
        get() {
            return moment(this.getDataValue('createdAt')).format('YYYY-MM-DD HH:mm:ss');
        }
    },
    updatedAt: {
        type: Sequelize.DATE,
        get() {
            return moment(this.getDataValue('updatedAt')).format('YYYY-MM-DD HH:mm:ss');
        }
    }
},{
    freezeTableName:true,
    paranoid:true,
    timestamps:true
})

let education = Education.sync();
module.exports = Education
